package com.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;

/**
 * @author wbzs,
 * @date 2022/10/23,
 * @time 22:26,
 */
@Component
public class MyRoutingFilter1 extends ZuulFilter {

    // 声明过滤器的类型
    @Override
    public String filterType() {

        //return "pre"
        return FilterConstants.ROUTE_TYPE;
    }


    //过滤器的顺序，数字越小，优先级越高
    @Override
    public int filterOrder() {
        return -1;
    }


    //是否启用当前过滤器
    @Override
    public boolean shouldFilter() {
        RequestContext currentContext = RequestContext.getCurrentContext();
        boolean b = currentContext.sendZuulResponse();


        return b;
    }

    @Override
    public Object run() throws ZuulException {
       System.err.println("run====>"+Thread.currentThread().getName());
        return null;
    }
}
